import {addresslist} from '../../utils/api'

const state={
    list:[]
}

const mutations={
    changelist(state,arr){
        state.list=arr
    }
}

const actions={
    reqchangelist(context,id){
        addresslist({uid:id}).then(res=>{
            console.log(res.data.list);
            let list=res.data.list?res.data.list:[]
            list.map((item) => {
                return (item.name = item.username), (item.tel = item.userphone),(item.address=item.location+item.useraddress);
              });
            context.commit('changelist',res.data.list)
        })
    }
}

const getters={
    list(state){
        return state.list
    }
}

export default{
    state,
    mutations,
    actions,
    getters,
    namespaced: true
}